package io.renren.modules.app.controller;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.GoodCouponUtil;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.PropertyUtil;
import io.renren.common.utils.R;

@RestController
@RequestMapping("/app/coupon")
public class CouponController {
	
	public static PropertyUtil propertyUtil = PropertyUtil.getInstance();
	
	/**
	 * 搜索商品优惠券
	 * @param goodName 2017年12月27日
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping("/list")
	public R listGoodCoupon(String goodName,Integer page,Integer limit,String cat){
		Integer page_size = limit == null ? 100 :limit;
		Integer page_no = page == null ? 1 :page;
		List<Map> couponList  = GoodCouponUtil.get(goodName, page_no, page_size, cat).toJavaList(Map.class);
		PageUtils pageUtil = new PageUtils(couponList, 10000, page_size, page_no);
		return R.ok().put("page", pageUtil);
	}

}
